<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="str" uri="/WEB-INF/config/tld/string-util.tld" %>
<jsp:include page="../include/header.jsp" />
<script type="text/javascript" src="<c:url value='/htmlRes/js/high_chart/highcharts.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/datepicker/jquery.ui.core.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/datepicker/jquery.ui.datepicker.js'/>"></script>
<script type="text/javaScript">
<!--
	$(document).ready(function(){
		$('.graph_box_02').each(function(index){
			var charId = $(this).attr('id');
			if($('#'+charId).html() != ""){
				var chartData = eval("("+$('#'+charId).html()+")");
				$('#'+charId).highcharts(chartData);
			}else{
				$('#'+charId).html("데이터가 없습니다.");
				$('#'+charId).css("text-align", "center");
				$('#'+charId).css("padding", "30px 0 0 0");
			}
		});
		
		$( "#searchSdate" ).datepicker();
		$( "#searchEdate" ).datepicker();
	});
	
	function searchForm(){
		$('#listForm').attr('action', '<c:url value="/daily/waterQuality.do"/>');
		$('#listForm').submit();
	}
	function excelDown(listCnt){
		if(listCnt == 0){
			alert('데이터가 없습니다.');
			return;
		}
		$('#listForm').attr('action', '<c:url value="/daily/waterQualityExcelDown.do"/>');
		$('#listForm').submit();
	}
-->
</script>
<!-- contents s -->
<div class="container" id="container">
	<span class="round lt" style="">&nbsp;</span>
	<span class="round rt">&nbsp;</span>
	<span class="round lb">&nbsp;</span>
	<span class="round rb">&nbsp;</span>
	<div class="container_area">
		<h2 class="tit_h2">수질현황</h2>
			<jsp:include page="../include/navi.jsp" />
			<span class="ico_print"><a href="#print"  onclick="printPage('<c:url value="/common/printView.do" />');return false;"><img src="/htmlRes/images/ico_print.jpg" alt="인쇄버튼"></a></span>
			<div class="srch_wrap">
				 <form name="listForm" id="listForm" method="post" action="<c:url value='/daily/waterQuality.do'/>">
					<fieldset>
						<legend>키워드 검색 조회 영역</legend>
						<c:if test="${loginSessionInfo.admin }">
						<select id=searchServiceArea name="searchServiceArea" title="현장 검색" onchange="searchForm();">
							<c:forEach var="result" items="${serviceareaList }"  varStatus="status">
								<option value="${result.ssa_area_key }" <c:if test="${result.ssa_area_key eq dailyVO.searchServiceArea}">selected="selected"</c:if>>${result.ssa_area_name }</option>
							</c:forEach>		
						</select>
						</c:if>
						<label for="searchSdate">기간 </label><input type="text" id="searchSdate" name="searchSdate" value="${dailyVO.searchSdate }"/> - <input type="text" id="searchEdate" name="searchEdate" value="${dailyVO.searchEdate }">
						<a href="<c:url value='/daily/waterQuality.do'/>" onclick="searchForm();return false;" class="btn_srch">검색</a>
						<a href="<c:url value='/daily/waterQualityExcelDown.do'/>" onclick="excelDown(${fn:length(resultList) });return false;" class="btn_exceldown">엑셀 다운로드</a>
					</fieldset>
				</form>
			</div>
			<div class="content_wrap">
				<div class="con_left">
					<div class="table_wrap height_m">
						<table summary="날짜, BOD, SS등 안내 테이블 입니다" class="table_list">
							<caption>날짜, BOD, SS등</caption>
								<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
									<col width="23%" />
									<col width="13%" />
									<col width="13%" />
									<col width="13%" />
									<col width="13%" />
									<col width="15%" />
									<col width="10%" />
								</colgroup>
								<thead>
									<tr>
										<th scope="col">날짜</th>
										<th scope="col">BOD<br /><span>(mg / L)</span></th>
										<th scope="col">SS<br /><span>(mg / L)</span></th>
										<th scope="col">T-N<br /><span>(mg / L)</span></th>
										<th scope="col">T-P<br /><span>(mg / L)</span></th>
										<th scope="col">총대장<br /><span>(개 / mL)</span></th>
										<th scope="col">첨부</th>
									</tr>
								</thead>
							<tbody>
							<c:set var="listCnt" value="0" />
							<c:forEach var="result" items="${resultList }" varStatus="status">
								<c:if test="${result.bodNum ne '0'}">
								<c:set var="listCnt" value="${listCnt+1 }" />
								<tr>
									<td>${result.dailyDate }</td>
									<td>${result.bodNum }</td>
									<td>${result.ssNum }</td>
									<td>${result.tnNum }</td>
									<td>${result.tpNum }</td>
									<td>${result.ecNum }</td>
									<td>
										<c:if test="${not empty result.dlogFile }">
											<c:set var="saveFile" value="${fn:split(result.dlogFile,'**')}" />
											<a href="<c:url value='/fileDownload.do'/>?fileInfo=${result.dlogFile}">@</a>
										</c:if>
									</td>
								</tr>
								</c:if>
							</c:forEach>
							<c:if test="${empty resultList or listCnt == 0}">
								<tr><td colspan="7">데이터가 없습니다</td></tr>
							</c:if>
							</tbody>
						</table>
					</div><!--//table_wrap-->
				</div><!--//con_left-->

				<div class="con_right">
					<div class="graph_area">
						<c:if test="${not empty resultMap }">
						<c:forEach var="chartMap" items="${resultMap.waterQualityChart }">
							<div class="graph_header"></div>
							<div id="${chartMap.key }" class="graph_box_02">${chartMap.value }</div>
						</c:forEach>
						</c:if>
						<c:if test="${empty resultMap }">
							<div class="graph_header"></div>
							<div id="bodNum" class="graph_box_02"></div>
						</c:if>
					</div>
				</div><!--//con_right-->
				
			</div><!--//content_wrap-->
	
	</div><!--//container_area-->
</div>
	<!-- contents e -->
<jsp:include page="../include/footer.jsp" />